package com.briup.jz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.briup.jz.bean.AccountEmployee;
import com.briup.jz.bean.AccountEmployeeExample;
import com.briup.jz.bean.AccountEmployeeExample.Criteria;
import com.briup.jz.dao.AccountEmployeeMapper;
import com.briup.jz.service.IAccountEmployeeService;
import com.briup.jz.utils.CustomerException;
@Service
public class AccountEmployeelmpl implements IAccountEmployeeService {
	@Autowired
   AccountEmployeeMapper accountEmployeeMapper;
	@Override
	public void saveOrUpdate(AccountEmployee accountEmployee) {
		// TODO Auto-generated method stub
		if(accountEmployee.getId()!=null)
		{
			accountEmployeeMapper.updateByPrimaryKey(accountEmployee);
		}
		else
		{
			accountEmployeeMapper.insert(accountEmployee);
		}
		;
		
	}

	@Override
	public List<AccountEmployee> query(Long userId) {
		// TODO Auto-generated method stub
		AccountEmployeeExample example=new AccountEmployeeExample();
		if(userId!=null)
		{
			example.createCriteria().andUserIdEqualTo(userId);
		}
		return accountEmployeeMapper.selectByExample(example);
	     
	
	}

	@Override
	public void deleteById(long id) {
		// TODO Auto-generated method stub
		AccountEmployee accountEmployee= accountEmployeeMapper.selectByPrimaryKey(id);
		if(accountEmployee!=null)
		{
			accountEmployeeMapper.deleteByPrimaryKey(id);
		}else {
		throw new CustomerException("要删除的分类信息不存在");
		}
	}

}
